# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=delve
pkgver=1.22.0
pkgrel=0
pkgdesc="Debugger for the Go programming language"
url="https://github.com/go-delve/delve"
arch="x86 x86_64 aarch64"
license="MIT"
makedepends="go"
options="net chmod-clean"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/go-delve/delve/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir bin
	go build -v -trimpath -o bin ./cmd/dlv/...
}

check() {
	# TestGeneratedDoc and TestBuild require a proper $GOPATH setup.
	go test -run '!(^(TestGeneratedDoc|TestBuild)$)' ./cmd/dlv/...
}

package() {
	install -Dm755 bin/* -t "$pkgdir"/usr/bin/

	# Install additional documentation files.
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	cp -r Documentation/* "$pkgdir"/usr/share/doc/$pkgname

	install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
4778bd08c96b6fda738ba752784e5acceb07c3c66118d749ec98372e7a8e42975d1173a9ed7b3a86c16ba2d61576d89b5fd1e765f1f4584678225749ee39048c  delve-1.22.0.tar.gz
"
